package system.student.funtion.exhibition.studentfunction.impl;

import system.student.entity.Course;
import system.student.entity.StudentCourseDetail;
import system.student.funtion.exhibition.studentfunction.ChoseCourseService;
import system.student.mapper.StudentMapper;
import system.student.util.LogRecordUtil;
import system.student.util.MapperUtil;

import java.util.List;

public class ChoseCourseServiceImpl implements ChoseCourseService {

    private StudentMapper studentMapper = MapperUtil.getMapper(StudentMapper.class);
    private StudentMapper studentMapperProxy = LogRecordUtil.wrap(studentMapper,StudentMapper.class);
    @Override
    public void choseCourse(Long courseId,Long studentId, String studentName) {
        studentMapperProxy.choseCourse(courseId, studentId, studentName);
    }

    @Override
    public List<Course> selectAllCourse() {

        return studentMapper.selectAllCourse();

    }

    @Override
    public boolean findIfHaveChosen(Long studentId, Long courseId) {
        return studentMapper.findByUserIdAndCourseId(studentId, courseId) != null;
    }

    @Override
    public List<StudentCourseDetail> findAllCourseByStudentId(Long id){
        StudentMapper mapper = MapperUtil.getMapper(StudentMapper.class);
        return mapper.findAllCourseByStudentId(id);
    }

    @Override
    public String findById(Long courseId ){
        return studentMapper.findById(courseId );
    }

    @Override
    public Integer findScoreByCourseName(String courseName ,Long studentId){
    	return studentMapper.findScoreByCourseName(courseName ,studentId);
    }

    @Override
    public void concelCourse(Long courseId, Long studentId) {
        StudentMapper studentMapperProxy = LogRecordUtil.wrap(studentMapper,StudentMapper.class);
        studentMapperProxy.concelCourse(courseId,studentId);
    }
}
